package cn.hrms.controller;

import cn.hrms.domain.dto.UserLoginBody;
import cn.hrms.domain.dto.UserRegisterBody;
import cn.hrms.domain.web.LoginInfo;
import cn.hrms.domain.web.R;
import cn.hrms.service.IUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 用户接口
 *
 * @author xiaokai54
 * @date 2024/12/17
 */
@Slf4j
@RestController
@RequestMapping("/admin/user")
@RequiredArgsConstructor
public class UserController extends BaseController {

	private final IUserService userService;

	@PostMapping("/login")
	public R<LoginInfo> login(@RequestBody UserLoginBody loginBody) {
		log.info("登录：{}", loginBody);
		LoginInfo res = userService.login(loginBody);
		return R.ok(res);
	}

	@PostMapping("/register")
	public R<Void> register(@RequestBody UserRegisterBody registerBody) {
		log.info("注册：{}", registerBody);
		userService.register(registerBody);
		return R.ok();
	}
}
